package com.fastdfs.controller;

import com.fastdfs.config.FastDFSConfig;
import com.fastdfs.util.FastDFSUtil;
import org.csource.common.MyException;
import org.csource.common.NameValuePair;
import org.csource.fastdfs.StorageClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

/**
 * Description
 * Author wangxh
 * Date 2020/7/16-3:43 下午
 * Version V1.0
 **/
@RestController
@RequestMapping(value = "/fastdfs")
public class FastDFSController {

    private static final Logger logger = LoggerFactory.getLogger(FastDFSController.class);

    @Autowired
    FastDFSUtil fastDFSUtil;


    @RequestMapping(value = "/upload")
    @ResponseBody
    public String upload(MultipartFile fastFile){
        try {
            return fastDFSUtil.uploadFile(fastFile);
        } catch (Exception e) {
            logger.error("上传文件失败" ,e );
        }
        return "";
    }

}
